package com.controller;

import com.pojo.Student;
import com.pojo.Sys_User;
import com.service.SysUserService;
import com.服务器端验证.Student2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;


@Controller
public class Sys_Controller {
    @Resource
    private SysUserService userService;
    //自动注入必须熟练掌握，第一种按名字找，找不到则按类型找且同一种类型只能有一个Bean
//    @Qualifier("Student")
//    @Resource(name = "getStudent2")
    @Autowired//对大小写敏感
    private Student student;


    @RequestMapping("/getAll")
    public String getAllSys_User(Student student,Map map){
        List<Sys_User> user_list = userService.selectAll();
        map.put("userlist",user_list);
        return "userlist.html";
    }
    @RequestMapping("/select")
    public String getSys_UserByLoginName(Map map, Sys_User user){
        Sys_User sys_user = userService.selectByLoginName(user);
        map.put("sys_user",sys_user);
        return "userByLoginName.html";
    }

    @RequestMapping("/stu")
    public String redirctStu(){
        return "客户端验证/student";
    }

    @RequestMapping("/yanzheng.do")
    public String 服务器端验证(@Valid Student2 student2){
        return "success";
    }

    @RequestMapping("/dd")
    public void 通过yml文件映射(){
        System.out.println(student);
    }

//    @Autowired
//    private Student student;
//
//    @RequestMapping("/stu/1")
//    public void 通过Configration注解注册Bean(){
//        System.out.println(student);
//    }
}
